{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "Python解释器作用：将代码文件解释器计算机能听懂语言。\n",
    "\n",
    "目录：\n",
    "C:\\Python38\n",
    "\t- python.exe        解释器\n",
    "\t- Scripts\n",
    "\t\t- pip.exe\n",
    "\t\t- pip3.exe\n",
    "\t\t- pip3.8.exe    安装Python第三方模块    pip install requests   pip install django\n",
    "\t- Lib  \n",
    "\t\t- random.py   内置功能\n",
    "\t\t- re.py        \n",
    "\t\t- site-packages\n",
    "\t\t\t- requests\n",
    "\t\t\t- django  web框架\n",
    "\t\t\t\n",
    "运行\n",
    "python demo.py"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "is_executing": true
   },
   "outputs": [],
   "source": [
    "# 单行注释 \n",
    "\"\"\"\n",
    "多行注释\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 数据类型\n",
    "int  float str bool list tuple dict set bytes  一切皆对象"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "print(200 - 100)\n",
    "print(\"hello\" + \" world\")\n",
    "print(\"12\" + \"10\")"
   ],
   "metadata": {
    "collapsed": false,
    "is_executing": true
   },
   "execution_count": null
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 类型转换\n",
    "str(123)   -> '123'  整型转字符串\n",
    "int('123') -> 123    字符串转整型\n",
    "bool(1)     -> True  整型转布尔\n",
    "所有的类型转换布尔值时，只有：None、0、空字符串、空字典、空列表、空元祖 -> False，其他均为True。"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "source": [
    "print(int('123') + int('456'))\n",
    "print(str(100) + str(200))\n",
    "\n",
    "print(bool(2))\n",
    "print(bool(-1))\n",
    "print(bool(0))  # F\n",
    "print(bool(' '))\n",
    "print(bool(''))  # F"
   ],
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "is_executing": true
    }
   },
   "outputs": [],
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "if [] or 0 or False or \"\" or None or () or {}:\n",
    "    print(1)\n",
    "else:\n",
    "    print(2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T05:19:48.278209600Z",
     "start_time": "2024-01-11T05:19:48.234965Z"
    }
   },
   "execution_count": 16
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n",
      "True\n",
      "False\n",
      "False\n",
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "print(int(\"8\") > 7)\n",
    "print(str(111) == 111)\n",
    "print(bool(-1))\n",
    "print(bool(0))\n",
    "print(bool(\"\"))\n",
    "print(bool(\"你好\"))\n",
    "print(bool(\"\") == bool(0))"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": 15
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# list  可变 增删是在原来的list里修改元素\n",
    "vlist = [\"上海\", \"青海\", \"江西\", 999]\n",
    "v2.append(000)\n",
    "print(len(v2))"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# tuple 不可变\n",
    "vtuple = (\"上海\", \"青海\", \"江西\", 999)"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# dict\n",
    "vdict = {\"name\": \"wsl\", \"age\": 19, \"email\": \"xxxxx\"}"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "root\n",
      "ROOT\n"
     ]
    }
   ],
   "source": [
    "# str 不可变 操作元素会复制一个 原来的不变\n",
    "name = \"root\"\n",
    "res = name.upper()\n",
    "\n",
    "print(name)  # \"root\"\n",
    "print(res)  # \"ROOT\""
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T01:41:35.070032800Z",
     "start_time": "2024-01-11T01:41:34.976365200Z"
    }
   },
   "execution_count": 2
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 条件语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "age = 30\n",
    "if age > 50:\n",
    "    print('成年了')\n",
    "elif age > 17:\n",
    "    print('老年')\n",
    "else:\n",
    "    print('未成年')"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "count = 0\n",
    "while count < 4:\n",
    "    print('hello')\n",
    "    count += 1\n",
    "    break"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "count = 0\n",
    "while count < 4:\n",
    "    print('hello')\n",
    "    count += 1\n",
    "    continue;"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "for i in range(2, 5):\n",
    "    print(i)"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(2, 5, 2):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "for i in [1, 2, 3, 4]:\n",
    "    print(i)"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入10\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "word = input('请输入')\n",
    "print(word)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### String  \n",
    "#### 转义\n",
    "\\n 换行\n",
    "\\t 代表4个空格\n",
    "\\b删除\n",
    "\\r覆盖\n",
    "R r 原始字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true,
    "ExecuteTime": {
     "end_time": "2024-01-10T08:57:45.812638200Z",
     "start_time": "2024-01-10T08:57:45.802643300Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "子曰:\"学而时习之，乐呵乐呵！\"    hello\n",
      "worldd   hello\tworld    hellworld    hello\n",
      "D:\\Program Files\\Python 3.8\\python.exe\n"
     ]
    }
   ],
   "source": [
    "print('子曰:\\\"学而时习之，乐呵乐呵！\\\"    hello\\n world   hello\\tworld    hello\\bworld    hello\\rworld')\n",
    "print(r'D:\\Program Files\\Python 3.8\\python.exe')"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "#### 格式化"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你好 王莎丽\n",
      "你好 王莎丽\n",
      "你好  王莎丽\n",
      "你好 王莎丽\n",
      "你好 王莎丽,18\n",
      "你好 王莎丽,18\n"
     ]
    }
   ],
   "source": [
    "name = '王莎丽'\n",
    "age = 18\n",
    "\n",
    "print(f'你好 {name}')\n",
    "print('你好 ' + name)\n",
    "print('你好 ', name)\n",
    "print('你好 {name}'.format(name=name))\n",
    "print('你好 {name},{age}'.format(name=name, age=age))\n",
    "print('你好 %s,%d' % (name, age))"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": 21
  },
  {
   "cell_type": "markdown",
   "source": [
    "### str 特有的函数"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "vstr1 = \"123\"\n",
    "vstr2 = \"qwe\"\n",
    "print(vstr1.isdecimal())  # 判断是否为整型\n",
    "print(vstr2.isdecimal())"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-10T09:07:58.398971300Z",
     "start_time": "2024-01-10T09:07:58.326339200Z"
    }
   },
   "execution_count": 31
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "223\n"
     ]
    }
   ],
   "source": [
    "if vstr1.isdecimal():\n",
    "    vstr1 = int(vstr1) + 100  #转成int\n",
    "    print(vstr1)\n",
    "else:\n",
    "    print(\"格式错误\")"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": 30
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "True\n",
      "0\n",
      "4\n",
      "1\n",
      "中国移动\n",
      "中国联通\n",
      "中国移动\n",
      "中国移动\n",
      "中国移动\n"
     ]
    }
   ],
   "source": [
    "vstr3 = \"中国移动\"\n",
    "\n",
    "print(vstr3.startswith('移动'))\n",
    "print(vstr3.endswith('移动'))\n",
    "print(vstr3.find(\"中\"))\n",
    "print(vstr3.count(\"中\"))\n",
    "print(vstr3.upper())\n",
    "print(vstr3.replace('移动', '联通'))\n",
    "print(vstr3.strip())  # 去掉首尾空格\n",
    "print(vstr3.lstrip())\n",
    "print(vstr3.rstrip())"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T01:57:38.349937400Z",
     "start_time": "2024-01-11T01:57:38.300845400Z"
    }
   },
   "execution_count": 9
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true,
    "ExecuteTime": {
     "end_time": "2024-01-11T01:57:26.497815800Z",
     "start_time": "2024-01-11T01:57:26.455796Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "张三_李四_周武\n",
      "['张三', '李四', '周武']\n",
      "李四,周武\n",
      "李四\n"
     ]
    }
   ],
   "source": [
    "vstr4 = [\"张三\", \"李四\", \"周武\"]\n",
    "print(\"_\".join(vstr4))\n",
    "\n",
    "vstr5 = \"张三,李四,周武\"\n",
    "print(vstr5.split(','))\n",
    "print(vstr5.split(\",\", maxsplit=1)[1])  #从第一次分隔符切割\n",
    "print(vstr5.rsplit(\",\")[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### Str 公共的函数\n",
    "长度/索引/切片/for /in"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "中\n",
      "通\n",
      "中\n",
      "国\n",
      "江\n",
      "西\n",
      "联\n",
      "通\n",
      "中\n",
      "国\n",
      "江\n",
      "西\n",
      "联\n",
      "通\n"
     ]
    }
   ],
   "source": [
    "name = \"中国江西联通\"\n",
    "print(len(name))\n",
    "print(name[0])\n",
    "print(name[-1])\n",
    "\n",
    "index = 0\n",
    "while index < len(name):\n",
    "    item = name[index]\n",
    "    print(item)\n",
    "    index += 1\n",
    "\n",
    "for i in name:\n",
    "    print(i)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:47:54.600640400Z",
     "start_time": "2024-01-11T06:47:54.554216700Z"
    }
   },
   "execution_count": 23
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "135\n",
      "12345\n",
      "1\n",
      "012345\n",
      "6789\n",
      "78\n",
      "3579\n",
      "0\n"
     ]
    }
   ],
   "source": [
    "str1 = '0123456789'\n",
    "print(str1[1:6:2])\n",
    "print(str1[1:6])\n",
    "print(str1[1])\n",
    "print(str1[:6])\n",
    "print(str1[6:])\n",
    "print(str1[-3:-1])  # 从后往前切\n",
    "print(str1[3:10:2])  # 切片 起始 结束 步长"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### list \n",
    "特有的功能：对元素的操作\n",
    "公共的功能：长度、索引、切片、for、in"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T02:17:30.696356300Z",
     "start_time": "2024-01-11T02:17:30.648309500Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "11"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vlist = [1, 3, 5, 6]\n",
    "vlist.append(7)\n",
    "vlist.insert(3, 0)\n",
    "vlist[0] = 11\n",
    "del vlist[2]\n",
    "vlist.remove(3)\n",
    "vlist.reverse()\n",
    "vlist.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T02:18:48.999320200Z",
     "start_time": "2024-01-11T02:18:48.956572700Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7\n",
      "6\n",
      "0\n",
      "7\n",
      "6\n",
      "0\n",
      "i=0:v=7\n",
      "i=1:v=6\n",
      "i=2:v=0\n",
      "[7, 6, 0]\n",
      "yes\n"
     ]
    }
   ],
   "source": [
    "index = 0\n",
    "while index < len(vlist):\n",
    "    print(vlist[index])\n",
    "    index += 1\n",
    "\n",
    "for i in vlist:\n",
    "    print(i)\n",
    "\n",
    "for i in range(len(vlist)):\n",
    "    print(f'i={i}:v={vlist[i]}')\n",
    "\n",
    "print(vlist)\n",
    "\n",
    "if 7 in vlist:\n",
    "    print('yes')"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### tuple \n",
    "无特有功能\n",
    "公共的功能:len/索引/切片/for/in"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "vt1 = (11, 22,)\n",
    "vt2 = ((1), (2),)"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "markdown",
   "source": [
    "### dict \n",
    "特有的功能：键值对\n",
    "公共的功能：不支持切片  索引、for、in、len"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"name\": \"wupeiqi\",\n",
    "    \"level\": \"13\",\n",
    "    \"hobby\": [\"篮球\", \"足球\"]\n",
    "}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T07:04:05.688743900Z",
     "start_time": "2024-01-11T07:04:05.635002200Z"
    }
   },
   "execution_count": 29
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'wupeiqi', 'level': '13', 'hobby': ['篮球', '足球'], 'add': 'test'}\n",
      "篮球\n",
      "足球\n"
     ]
    }
   ],
   "source": [
    "info['add'] = \"test\"\n",
    "print(info)\n",
    "\n",
    "keys = info['hobby']\n",
    "for i in keys:\n",
    "    print(i)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T07:05:49.841059800Z",
     "start_time": "2024-01-11T07:05:49.794641300Z"
    }
   },
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T02:36:39.041473200Z",
     "start_time": "2024-01-11T02:36:38.991373100Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wupeiqi\n",
      "name\n",
      "level\n",
      "hobby\n",
      "wupeiqi\n",
      "13\n",
      "['篮球', '足球']\n",
      "('name', 'wupeiqi')\n",
      "('level', '13')\n",
      "('hobby', ['篮球', '足球'])\n",
      "key = name value = wupeiqi\n",
      "key = level value = 13\n",
      "key = hobby value = ['篮球', '足球']\n"
     ]
    }
   ],
   "source": [
    "print(info.get('name'))\n",
    "\n",
    "#删除\n",
    "#del info['name']\n",
    "#print(info.pop('name'))\n",
    "\n",
    "for data in info.keys():\n",
    "    print(data)\n",
    "\n",
    "for data in info.values():\n",
    "    print(data)\n",
    "\n",
    "for item in info.items():\n",
    "    print(item)\n",
    "\n",
    "for key, value in info.items():\n",
    "    print('key = %s' % key, 'value = %s' % value)"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 编码"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b'\\xe7\\x8e\\x8b\\xe8\\x8e\\x8e\\xe4\\xb8\\xbd'\n",
      "王莎丽 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "vn1 = '王莎丽'\n",
    "vn2 = vn1.encode('utf-8')  # str -> unicode byte\n",
    "print(vn2)\n",
    "\n",
    "vn1 = vn2.decode('utf-8')\n",
    "print(vn1, type(vn1))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T05:34:05.249800700Z",
     "start_time": "2024-01-11T05:34:05.232624200Z"
    }
   },
   "execution_count": 18
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 文件"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# b byte 写入/读取文件的类型是byte 图片视频需要用b  txt不用b\n",
    "# w：文件不存在则创建文件 + 打开前清空  \n",
    "# a:追加\n",
    "# 相对位置是剪辑器的位置  \n",
    "name = \"青海\\n联通\"\n",
    "data = name.encode('utf-8')\n",
    "\n",
    "f = open(\"a.txt\", mode='wb')\n",
    "f.write(data)\n",
    "f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:04:44.413084300Z",
     "start_time": "2024-01-11T06:04:44.347574500Z"
    }
   },
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "青海\n",
      "联通\n"
     ]
    }
   ],
   "source": [
    "f = open(\"a.txt\", mode='rb')\n",
    "content = f.read()  # 读到内存\n",
    "f.close()\n",
    "data_str = content.decode('utf-8')  #byte->str\n",
    "print(data_str)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:07:10.210487Z",
     "start_time": "2024-01-11T06:07:10.134434800Z"
    }
   },
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "while True:\n",
    "    name = input(\"姓名:\")\n",
    "    if name.upper() == 'Q':\n",
    "        break\n",
    "\n",
    "    line = \"{}\\n\".format(name)\n",
    "    data = line.encode('utf-8')\n",
    "    f = open(\"a.txt\", mode='ab')\n",
    "    f.write(data)\n",
    "    f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:11:05.129688800Z",
     "start_time": "2024-01-11T06:10:55.253737900Z"
    }
   },
   "execution_count": 4
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 大文件"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "按行读"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "26044585,Hush,https://hbimg.huabanimg.com/51d46dc32abe7ac7f83b94c67bb88cacc46869954f478-aP4Q3V\n",
      "15529690,Law344,https://hbimg.huabanimg.com/b438d8c61ed2abf50ca94e00f257ca7a223e3b364b471-xrzoQd\n",
      "18311394,Jennah·,https://hbimg.huabanimg.com/4edba1ed6a71797f52355aa1de5af961b85bf824cb71-px1nZz\n",
      "30574436,花姑凉~,https://hbimg.huabanimg.com/2f5b657edb9497ff8c41132e18000edb082d158c2404-8rYHbw\n"
     ]
    }
   ],
   "source": [
    "f = open(\"b.txt\", mode='r', encoding='utf-8')\n",
    "for line in f:\n",
    "    line = line.strip()\n",
    "    if not line:\n",
    "        continue\n",
    "    print(line)\n",
    "\n",
    "f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T10:12:08.997590800Z",
     "start_time": "2024-01-11T10:12:08.907143300Z"
    }
   },
   "execution_count": 48
  },
  {
   "cell_type": "markdown",
   "source": [
    "按照大小分批读"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "# 读取文件大小（字节）\n",
    "total_size = os.stat(\"b.txt\").st_size\n",
    "print(total_size)\n",
    "\n",
    "f = open(\"b.txt\", mode='rb')\n",
    "has_read_size = 0\n",
    "while has_read_size < total_size:\n",
    "    chunk = f.read(3)\n",
    "    print(chunk)\n",
    "    has_read_size = has_read_size + len(chunk)\n",
    "\n",
    "f.close()"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "markdown",
   "source": [
    "with 不用手动关闭资源"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "with open(\"db.txt\", mode='r', encoding=\"utf-8\") as f:\n",
    "    content = f.read()\n",
    "    print(content)"
   ],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  },
  {
   "cell_type": "markdown",
   "source": [
    "### request"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"code\":0,\"data\":{\"count\":15630,\"next\":\"/api/v1/result/enroll/?limit=1&offset=21&resultType=enroll\",\"previous\":\"/api/v1/result/enroll/?limit=1&offset=19&resultType=enroll\",\"result\":[{\"stu_info\":{\"username\":\"林**\",\"avatar\":\"//hcdn2.luffycity.com/media/frontend/head_portrait/logo@2x.png\",\"company\":\"茂**安\",\"position\":\"维修技师\"},\"enroll_course\":\"Python开发副业山顶会\",\"enroll_level\":\"中级\",\"review_date\":\"2024-01-14\",\"why_take_this_course\":\"学多门技术  增加收入\",\"why_choose_us\":\"缘分\",\"your_expectation\":\"学到知识   提高收入\"}]}}\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "\n",
    "res = requests.get(\"https://api.luffycity.com/api/v1/result/enroll/?resultType=enroll&limit=1&offset=20\")\n",
    "f = open(\"a.txt\", mode=\"wb\")\n",
    "f.write(res.content)\n",
    "f.close()\n",
    "\n",
    "f = open(\"a.txt\", mode='rb')\n",
    "content = f.read()\n",
    "f.close()\n",
    "text = content.decode('utf-8')\n",
    "print(text)\n",
    "#text=res.content.decode('utf-8')\n",
    "new_text = text.replace(\"code\", \"codeing\")\n",
    "f = open(\"newa.txt\", \"wb\")\n",
    "f.write(new_text.encode('utf-8'))\n",
    "f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-16T08:43:19.252803600Z",
     "start_time": "2024-01-16T08:43:18.466403700Z"
    }
   },
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "while True:\n",
    "\n",
    "    key = input(\"请输入要搜索的关键字：\")\n",
    "    if key == 'q':\n",
    "        break\n",
    "    res = requests.post(\n",
    "        url=\"https://jf.10086.cn/cmcc-web-shop/search/query\",\n",
    "        data={\n",
    "            \"sortColumn\": \"default\",\n",
    "            \"sortType\": \"DESC\",\n",
    "            \"pageSize\": \"60\",\n",
    "            \"pageNum\": \"1\",\n",
    "            \"firstKeyword\": key,\n",
    "            \"integral\": \"\",\n",
    "            \"province\": \"\",\n",
    "        },\n",
    "        headers={\n",
    "            \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36\"\n",
    "        }\n",
    "    )\n",
    "\n",
    "    text_string = res.text\n",
    "\n",
    "    print(text_string)"
   ],
   "metadata": {
    "collapsed": false,
    "is_executing": true
   },
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'code': 0, 'data': {'count': 15554, 'next': '/api/v1/result/enroll/?limit=5&offset=25&resultType=enroll', 'previous': '/api/v1/result/enroll/?limit=5&offset=15&resultType=enroll', 'result': [{'stu_info': {'username': '付**', 'avatar': '//hcdn2.luffycity.com/media/frontend/head_portrait/logo@2x.png', 'company': 'h*****司', 'position': '大数据工程师'}, 'enroll_course': '2023路飞爬虫 & 逆向', 'enroll_level': '中级', 'review_date': '2024-01-09', 'why_take_this_course': '挣钱，学习python技术和爬虫技术，', 'why_choose_us': '看年卡课程还可以', 'your_expectation': '能有稳定副业，副业年入100w'}, {'stu_info': {'username': '石**', 'avatar': '//hcdn2.luffycity.com/media/frontend/head_portrait/logo@2x.png', 'company': '无', 'position': '无'}, 'enroll_course': 'Python全栈开发（中级）', 'enroll_level': '中级', 'review_date': '2024-01-09', 'why_take_this_course': '马上毕业准备就业技能', 'why_choose_us': '在抖音上关注到了 感觉会有帮助', 'your_expectation': '希望能达到行业的中等水平'}, {'stu_info': {'username': '胡**', 'avatar': '//hcdn2.luffycity.com/media/frontend/head_portrait/2f7b1cb6714caa57558d8d6648c13822.png', 'company': '深**********司', 'position': 'python开发'}, 'enroll_course': 'Python开发副业山顶会', 'enroll_level': '中级', 'review_date': '2024-01-09', 'why_take_this_course': '挣钱', 'why_choose_us': '抖音上了解的 看重你们平台的师资力量', 'your_expectation': '每月副业收入能达到1.5W'}, {'stu_info': {'username': '胡**', 'avatar': '//hcdn2.luffycity.com/media/frontend/head_portrait/2f7b1cb6714caa57558d8d6648c13822.png', 'company': '深**********司', 'position': 'python开发'}, 'enroll_course': '2023路飞爬虫 & 逆向', 'enroll_level': '中级', 'review_date': '2024-01-09', 'why_take_this_course': '挣钱', 'why_choose_us': '抖音上了解的 比较看重你们平台的师资力量', 'your_expectation': '副业月入1.5W'}, {'stu_info': {'username': '朱**', 'avatar': '//hcdn2.luffycity.com/media/frontend/head_portrait/c30d24f55a711f6401bd1c01e4367ccd.png', 'company': '无', 'position': '软件测试'}, 'enroll_course': '2023路飞爬虫 & 逆向', 'enroll_level': '中级', 'review_date': '2024-01-09', 'why_take_this_course': '通过副业提高收入', 'why_choose_us': '之前抖音购买过黑卡，觉得课程还不错', 'your_expectation': '掌握技术，通过兼职接单提高收入'}]}}\n"
     ]
    }
   ],
   "source": [
    "res = requests.get(\"https://api.luffycity.com/api/v1/result/enroll/?resultType=enroll&limit=5&offset=20\")\n",
    "data_dict = res.json()\n",
    "\n",
    "print(data_dict)\n",
    "\n",
    "f = open(\"news.txt\", mode='ab')\n",
    "\n",
    "for item in data_dict['data']['result']:\n",
    "    review_date = item['review_date']\n",
    "why_choose_us = item['why_choose_us']\n",
    "\n",
    "line = \"{}|{}\\n\".format(review_date, why_choose_us)\n",
    "\n",
    "f.write(line.encode('utf-8'))\n",
    "f.flush()\n",
    "f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:38:40.443698400Z",
     "start_time": "2024-01-11T06:38:39.496860800Z"
    }
   },
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "img_list = [\n",
    "    {\"name\": \"266.png\", 'url': \"https://hbimg.huabanimg.com/51d46dc32abe7ac7f83b94c67bb88cacc46869954f478-aP4Q3V\"},\n",
    "    {\"name\": \"193.png\", 'url': \"https://hbimg.huabanimg.com/703fdb063bdc37b11033ef794f9b3a7adfa01fd21a6d1-wTFbnO\"},\n",
    "    {\"name\": \"300.png\", 'url': \"https://hbimg.huabanimg.com/2f5b657edb9497ff8c41132e18000edb082d158c2404-8rYHbw\"},\n",
    "]\n",
    "\n",
    "for info in img_list:\n",
    "    file_name = info['name']\n",
    "url = info['url']\n",
    "\n",
    "res = requests.get(url)\n",
    "f = open(file_name, mode='wb')\n",
    "f.write(res.content)\n",
    "f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T08:05:22.795845300Z",
     "start_time": "2024-01-11T08:05:21.332192300Z"
    }
   },
   "execution_count": 38
  },
  {
   "cell_type": "markdown",
   "source": [
    "26044585,Hush,https://hbimg.huabanimg.com/51d46dc32abe7ac7f83b94c67bb88cacc46869954f478-aP4Q3V\n",
    "19318369,柒十一,https://hbimg.huabanimg.com/703fdb063bdc37b11033ef794f9b3a7adfa01fd21a6d1-wTFbnO\n",
    "15529690,Law344,https://hbimg.huabanimg.com/b438d8c61ed2abf50ca94e00f257ca7a223e3b364b471-xrzoQd\n",
    "18311394,Jennah·,https://hbimg.huabanimg.com/4edba1ed6a71797f52355aa1de5af961b85bf824cb71-px1nZz\n",
    "30574436,花姑凉~,https://hbimg.huabanimg.com/2f5b657edb9497ff8c41132e18000edb082d158c2404-8rYHbw"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['26044585,Hush,https://hbimg.huabanimg.com/51d46dc32abe7ac7f83b94c67bb88cacc46869954f478-aP4Q3V', '19318369,柒十一,https://hbimg.huabanimg.com/703fdb063bdc37b11033ef794f9b3a7adfa01fd21a6d1-wTFbnO', '15529690,Law344,https://hbimg.huabanimg.com/b438d8c61ed2abf50ca94e00f257ca7a223e3b364b471-xrzoQd', '18311394,Jennah·,https://hbimg.huabanimg.com/4edba1ed6a71797f52355aa1de5af961b85bf824cb71-px1nZz', '30574436,花姑凉~,https://hbimg.huabanimg.com/2f5b657edb9497ff8c41132e18000edb082d158c2404-8rYHbw']\n"
     ]
    }
   ],
   "source": [
    "f = open(\"b.txt\", mode=\"rb\")\n",
    "content = f.read()\n",
    "f.close()\n",
    "\n",
    "data_list = content.decode('utf-8').strip().replace(\"\\r\", \"\").split(\"\\n\")\n",
    "print(data_list)\n",
    "for line in data_list:\n",
    "    info_list = line.split(\",\")\n",
    "file_name = \"{}.png\".format(info_list[0])\n",
    "url = info_list[2]\n",
    "res = requests.get(url)\n",
    "img = open(file_name, \"wb\")\n",
    "img.write(res.content)\n",
    "img.close\n"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T08:11:06.463917400Z",
     "start_time": "2024-01-11T08:11:03.689800200Z"
    }
   },
   "execution_count": 41
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "f = open(\"newa.txt\", \"wb\")\n",
    "while True:\n",
    "    name = input(\"用户名\")\n",
    "    if name.upper() == 'Q':\n",
    "        break\n",
    "\n",
    "    pwd = input(\"密码:\")\n",
    "    email = input(\"邮箱:\")\n",
    "    line = '{},{},{}\\n'.format(name, pwd, email)\n",
    "\n",
    "    f.write(line.encode('utf-8'))\n",
    "    f.flush()\n",
    "    f.close()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:31:12.429759500Z",
     "start_time": "2024-01-11T06:31:05.230281400Z"
    }
   },
   "execution_count": 15
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 练习"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['京A1192'] 1\n"
     ]
    }
   ],
   "source": [
    "datas = (\"京A1192\", \"沪B99999\", \"黑A887833\")\n",
    "data_list = []\n",
    "for ele in datas:\n",
    "    if ele.startswith(\"京\"):\n",
    "        data_list.append(ele)\n",
    "\n",
    "print(data_list, len(data_list))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T02:41:44.554899400Z",
     "start_time": "2024-01-11T02:41:44.510878100Z"
    }
   },
   "execution_count": 34
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "v1 = (\"alexC\", \"AbC \", \"egon\", \" riTiAn\", \"WuSir\", \"  aqc\")\n",
    "data_list2 = []\n",
    "for item in v1:\n",
    "    if item.strip().startswith('a'):\n",
    "        data_list2.append(item)\n",
    "\n",
    "print(len(data_list2))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-16T06:30:12.940474700Z",
     "start_time": "2024-01-16T06:30:12.921288900Z"
    }
   },
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'wsl': '19'}\n"
     ]
    }
   ],
   "source": [
    "info = {}\n",
    "text = input('请输入‘用户名，密码’：')\n",
    "info_list = text.split(',')\n",
    "k = info_list[0]\n",
    "v = info_list[1]\n",
    "info[k] = v\n",
    "print(info)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T02:44:24.474427300Z",
     "start_time": "2024-01-11T02:44:12.582928500Z"
    }
   },
   "execution_count": 38
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'username': 'wsl', 'password': '123'}\n"
     ]
    }
   ],
   "source": [
    "info = {}\n",
    "while True:\n",
    "    name = input('请输入名称：')\n",
    "    if name.upper() == 'Q':\n",
    "        break\n",
    "    pwd = input('密码:')\n",
    "\n",
    "    info['username'] = name\n",
    "    info['password'] = pwd\n",
    "print(info)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T02:57:02.009715300Z",
     "start_time": "2024-01-11T02:56:56.223216100Z"
    }
   },
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "价格必须为数字\n",
      "[{'title': '1', 'price': '1'}]\n"
     ]
    }
   ],
   "source": [
    "# 减少if else\n",
    "# 简单的先处理\n",
    "# 1.录入商品\n",
    "goods = []\n",
    "while True:\n",
    "    title = input(\"标题\")\n",
    "    if title.upper() == 'Q':\n",
    "        break\n",
    "\n",
    "    price = input(\"价格\")\n",
    "    if not price.isdecimal():\n",
    "        print(\"价格必须为数字\")\n",
    "        continue\n",
    "\n",
    "    info = {\"title\": title, \"price\": price}\n",
    "    goods.append(info)\n",
    "\n",
    "print(goods)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T03:06:29.845941900Z",
     "start_time": "2024-01-11T03:06:20.408346900Z"
    }
   },
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.电脑,价格：1000\n",
      "2.手机,价格：2000\n",
      "{'title': '电脑', 'price': 1000}\n"
     ]
    }
   ],
   "source": [
    "# 2.展示商品\n",
    "goods = [\n",
    "    {\"title\": \"电脑\", 'price': 1000},\n",
    "    {\"title\": \"手机\", 'price': 2000},\n",
    "]\n",
    "\n",
    "for i in range(len(goods)):\n",
    "    info_dict = goods[i]\n",
    "    print(\"{}.{},价格：{}\".format(i + 1, info_dict['title'], info_dict['price']))\n",
    "\n",
    "choice = input('请选择序号：')\n",
    "if not choice.isdecimal():\n",
    "    print('输入错误序号')\n",
    "else:\n",
    "    choice = int(choice)\n",
    "    if choice < 1 or choice > len(goods):\n",
    "        print('范围错误')\n",
    "    else:\n",
    "        print(goods[int(choice) - 1])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T05:13:06.277256900Z",
     "start_time": "2024-01-11T05:13:02.825294400Z"
    }
   },
   "execution_count": 9
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 xxxx ...\n",
      "2 xxxx ...\n"
     ]
    }
   ],
   "source": [
    "info = {\n",
    "    \"code\": \"True\",\n",
    "    \"data\": [\n",
    "        {\"id\": '1', \"title\": \"xxxx\", \"url\": \"...\"},\n",
    "        {\"id\": '2', \"title\": \"xxxx\", \"url\": \"...\"}\n",
    "    ]\n",
    "}\n",
    "\n",
    "for item in info['data']:\n",
    "    print(item['id'], item['title'], item['url'])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:32:58.371650300Z",
     "start_time": "2024-01-11T06:32:58.283668300Z"
    }
   },
   "execution_count": 16
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 xxxx ...\n",
      "2 xxxx ...\n"
     ]
    }
   ],
   "source": [
    "info = {\n",
    "    \"code\": \"True\",\n",
    "    \"data\": {\n",
    "        \"count\": 1000,\n",
    "        \"result\": [\n",
    "            {\"id\": '1', \"title\": \"xxxx\", \"url\": \"...\"},\n",
    "            {\"id\": '2', \"title\": \"xxxx\", \"url\": \"...\"}\n",
    "        ]\n",
    "    }\n",
    "}\n",
    "\n",
    "for item in info['data']['result']:\n",
    "    print(item['id'], item['title'], item['url'])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:35:27.563923400Z",
     "start_time": "2024-01-11T06:35:27.478664800Z"
    }
   },
   "execution_count": 19
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SH601778,N晶科,6.29,+1.92,+43.94%,+43.94%,259.66万,1625.52万,0.44%,22.32,-,173.95亿\r\n",
      "SH688566,吉贝尔,52.66,+6.96,+15.23%,+122.29%,1626.58万,8.09亿,42.29%,89.34,-,98.44亿\r\n",
      "SH688268,华特气体,88.80,+11.72,+15.20%,+102.51%,622.60万,5.13亿,22.87%,150.47,-,106.56亿\r\n",
      "SH600734,实达集团,2.60,+0.24,+10.17%,-61.71%,1340.27万,3391.14万,2.58%,亏损,0.00%,16.18亿\r\n",
      "SH900957,凌云B股,0.36,+0.033,+10.09%,-35.25%,119.15万,42.10万,0.65%,44.65,0.00%,1.26亿\r\n",
      "SZ000584,哈工智能,6.01,+0.55,+10.07%,-4.15%,2610.86万,1.53亿,4.36%,199.33,0.26%,36.86亿\r\n",
      "SH600599,熊猫金控,6.78,+0.62,+10.06%,-35.55%,599.64万,3900.23万,3.61%,亏损,0.00%,11.25亿\r\n",
      "SH600520,文一科技,8.21,+0.75,+10.05%,-24.05%,552.34万,4464.69万,3.49%,亏损,0.00%,13.01亿\r\n",
      "SH603682,锦和商业,11.73,+1.07,+10.04%,+48.29%,2746.63万,3.15亿,29.06%,29.62,-,55.42亿\r\n",
      "SZ300831,派瑞股份,12.27,+1.12,+10.04%,+208.29%,25.38万,311.41万,0.32%,60.59,-,39.26亿\n"
     ]
    }
   ],
   "source": [
    "f = open(\"b.txt\", mode=\"rb\")\n",
    "content = f.read()\n",
    "f.close()\n",
    "\n",
    "data = content.decode('utf-8').strip()\n",
    "print(data)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T06:57:31.280318200Z",
     "start_time": "2024-01-11T06:57:31.234240900Z"
    }
   },
   "execution_count": 25
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'SH601778': 'N晶科', 'SH688566': '吉贝尔', 'SH688268': '华特气体', 'SH600734': '实达集团', 'SH900957': '凌云B股', 'SZ000584': '哈工智能', 'SH600599': '熊猫金控', 'SH600520': '文一科技', 'SH603682': '锦和商业', 'SZ300831': '派瑞股份'}\n"
     ]
    }
   ],
   "source": [
    "result = {}\n",
    "for item in data.split('\\n'):\n",
    "    group = item.split(\",\")\n",
    "    result[group[0] == group[1]]\n",
    "\n",
    "    print(result)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-11T07:02:04.126276400Z",
     "start_time": "2024-01-11T07:02:04.073169100Z"
    }
   },
   "execution_count": 27
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
